from typedef cimport *
from adapter cimport *
from render cimport *
from base cimport *

cdef extern from 'stdafx.h':
    ctypedef struct ISouiFactoryVtbl:
        IApplication* CreateApp(ISouiFactory* this, IRenderFactory*pRenderFac,HMODULE hInst,LPCTSTR pszHostClassName, BOOL bImeApp)
        INativeWnd* CreateNativeWnd(ISouiFactory* this)
        IHostWnd* CreateHostWnd(ISouiFactory* this, LPCTSTR pszResID)
        IHostDialog* CreateHostDialog(ISouiFactory* this, LPCTSTR pszResID)
        IStringA* CreateStringA(ISouiFactory* this, LPCSTR pszSrc)
        IStringW* CreateStringW(ISouiFactory* this, LPCWSTR pszSrc)
        IXmlDoc* CreateXmlDoc(ISouiFactory* this)
        IResProvider* CreateResProvider(ISouiFactory* this, BUILTIN_RESTYPE resType)
        IEvtSlot* CreateFuncSlot(ISouiFactory* this, FunCallback fun, void*ctx)
        IMenu* CreateMenu(ISouiFactory* this, HMENU hMenu)
        IMenuEx* CreateMenuEx(ISouiFactory* this)

    ctypedef struct ISouiFactory: # (IObjRef)
        ISouiFactoryVtbl* lpVtbl

    ctypedef struct IApplicationVtbl:
        HMODULE GetModule(IApplication* this)
        UINT LoadSystemNamedResource(IApplication* this, IResProvider* pResProvider)
        ITranslatorMgr* GetTranslator(IApplication* this)
        void SetTranslator(IApplication* this, ITranslatorMgr* pTrans)
        IToolTipFactory* GetToolTipFactory(IApplication* this)
        void SetToolTipFactory(IApplication* this, IToolTipFactory* pToolTipFac)
        BOOL SetMsgLoopFactory(IApplication* this, IMsgLoopFactory* pMsgLoopFac)
        IMsgLoopFactory* GetMsgLoopFactory(IApplication* this)
        void SetLogManager(IApplication* this, ILogMgr* pLogMgr)
        ILogMgr* GetLogManager(IApplication* this)
        void SetAttrStorageFactory(IApplication* this, IAttrStorageFactory* pAttrStorageFactory)
        IAttrStorageFactory* GetAttrStorageFactory(IApplication* this)
        int Run(IApplication* this, HWND hMainWnd)
        HWND GetMainWnd(IApplication* this)
        BOOL AddMsgLoop(IApplication* this, IMessageLoop* pMsgLoop, BOOL bReplace)
        BOOL RemoveMsgLoop(IApplication* this)
        IMessageLoop* GetMsgLoop(IApplication* this, DWORD dwThreadID)
        IResProviderMgr* GetResProviderMgr(IApplication* this)
        IRealWndHandler* GetRealWndHander(IApplication* this)
        void SetRealWndHandler(IApplication* this, IRealWndHandler* pRealHandler)
        IRenderFactory* GetRenderFactory(IApplication* this)
        void SetScriptFactory(IApplication* this, IScriptFactory* pScriptModule)
        void InitXmlNamedID(IApplication* this, const LPCWSTR*pNames, const int*nIds, int nCount)
        IXmlDoc* LoadXmlDocment(IApplication* this, LPCTSTR strResId)
        IAnimation* LoadAnimation(IApplication* this, LPCTSTR strResId)
        IValueAnimator* LoadValueAnimator(IApplication* this, LPCTSTR strResId)
        void EnableNotifyCenter(IApplication* this, BOOL bEnable,int interval)
        void* GetInnerSingleton(IApplication* this, SingletonType type)
        IObject* CreateObject(IApplication* this, LPCWSTR pszName,SObjectType nType)
        # void SetCreateObjectCallback(IApplication* this, FunCreateObject cbCreateObj)

    ctypedef struct IApplication: # (IObjRef)
        IApplicationVtbl* lpVtbl

    ctypedef struct INotifyCenterVtbl:
        void FireEventSync(INotifyCenter* this, IEvtArgs*e)
        void FireEventAsync(INotifyCenter* this, IEvtArgs*e)
        BOOL RegisterEventMap(INotifyCenter* this, const IEvtSlot*slot)
        BOOL UnregisterEventMap(INotifyCenter* this, const IEvtSlot*slot)
        void RunOnUI(INotifyCenter* this, IRunnable* pRunnable,BOOL bSync)
        void RunOnUI2(INotifyCenter* this, FunRunOnUI fun, WPARAM wp, LPARAM lp,BOOL bSync)

    ctypedef struct INotifyCenter:
        INotifyCenterVtbl* lpVtbl

    ctypedef struct INativeWndVtbl:
        HWND CreateNative(INativeWnd* this, LPCTSTR lpWindowName, DWORD dwStyle, DWORD dwExStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, int nID, LPVOID lpParam)
        HWND GetHwnd(INativeWnd* this)
        BOOL SubclassWindow(INativeWnd* this, HWND hWnd)
        HWND UnsubclassWindow(INativeWnd* this, BOOL bForce)
        const MSG* GetCurrentMessage(const INativeWnd* this)
        int GetDlgCtrlID(const INativeWnd* this)
        DWORD GetStyle(const INativeWnd* this)
        DWORD GetExStyle(const INativeWnd* this)
        LONG_PTR GetWindowLongPtr(const INativeWnd* this, int nIndex)
        LONG_PTR SetWindowLongPtr(INativeWnd* this, int nIndex, LONG_PTR dwNewLong)
        HWND GetParent(INativeWnd* this)
        HWND SetParent(INativeWnd* this, HWND hWndNewParent)
        BOOL IsWindowEnabled(const INativeWnd* this)
        BOOL ModifyStyle(INativeWnd* this, DWORD dwRemove, DWORD dwAdd, UINT nFlags)
        BOOL ModifyStyleEx(INativeWnd* this, DWORD dwRemove, DWORD dwAdd, UINT nFlags)
        BOOL SetWindowPos(INativeWnd* this, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
        BOOL CenterWindow(INativeWnd* this, HWND hWndCenter)
        BOOL DestroyWindow(INativeWnd* this)
        BOOL IsWindow(INativeWnd* this)
        BOOL Invalidate(INativeWnd* this, BOOL bErase)
        BOOL InvalidateRect(INativeWnd* this, LPCRECT lpRect, BOOL bErase)
        BOOL GetWindowRect(const INativeWnd* this, LPRECT lpRect)
        BOOL GetClientRect(const INativeWnd* this, LPRECT lpRect)
        BOOL ClientToScreen(const INativeWnd* this, LPPOINT lpPoint)
        BOOL ClientToScreen2(const INativeWnd* this, LPRECT lpRect)
        BOOL ScreenToClient(const INativeWnd* this, LPPOINT lpPoint)
        BOOL ScreenToClient2(const INativeWnd* this, LPRECT lpRect)
        int MapWindowPoints(const INativeWnd* this, HWND hWndTo, LPPOINT lpPoint, UINT nCount)
        int MapWindowRect(const INativeWnd* this, HWND hWndTo, LPRECT lpRect)
        UINT_PTR SetTimer(INativeWnd* this, UINT_PTR nIDEvent, UINT nElapse, FunTimerCallBack lpfnTimer)
        BOOL KillTimer(INativeWnd* this, UINT_PTR nIDEvent)
        HDC GetDC(INativeWnd* this)
        HDC GetWindowDC(INativeWnd* this)
        int ReleaseDC(INativeWnd* this, HDC hDC)
        BOOL CreateCaret(INativeWnd* this, HBITMAP hBitmap, int nWidth, int nHeight)
        BOOL HideCaret(INativeWnd* this)
        BOOL ShowCaret(INativeWnd* this)
        HWND GetCapture(INativeWnd* this)
        HWND SetCapture(INativeWnd* this)
        BOOL ReleaseCapture(INativeWnd* this)
        HWND SetFocus(INativeWnd* this)
        LRESULT SendMessage(INativeWnd* this, UINT message, WPARAM wParam, LPARAM lParam)
        BOOL PostMessage(INativeWnd* this, UINT message, WPARAM wParam, LPARAM lParam)
        BOOL SendNotifyMessage(INativeWnd* this, UINT message, WPARAM wParam, LPARAM lParam)
        BOOL SetWindowText(INativeWnd* this, LPCTSTR lpszString)
        int GetWindowText(const INativeWnd* this, LPTSTR lpszStringBuf, int nMaxCount)
        BOOL IsIconic(const INativeWnd* this)
        BOOL IsZoomed(const INativeWnd* this)
        BOOL IsWindowVisible(const INativeWnd* this)
        BOOL MoveWindow(INativeWnd* this, int x, int y, int nWidth, int nHeight, BOOL bRepaint)
        BOOL MoveWindow2(INativeWnd* this, LPCRECT lpRect, BOOL bRepaint)
        BOOL ShowWindow(INativeWnd* this, int nCmdShow)
        int SetWindowRgn(INativeWnd* this, HRGN hRgn, BOOL bRedraw)
        BOOL SetLayeredWindowAttributes(INativeWnd* this, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)
        # BOOL UpdateLayeredWindow(INativeWnd* this, HDC hdcDst, POINT* pptDst, SIZE* psize, HDC hdcSrc, POINT* pptSrc, COLORREF crKey, BLENDFUNCTION* pblend, DWORD dwFlags)
        void SetMsgHandler(INativeWnd* this, FunMsgHandler fun, void*ctx)
        # MsgHandlerInfo* GetMsgHandler(INativeWnd* this)

    ctypedef struct INativeWnd: # (IObjRef)
        INativeWndVtbl* lpVtbl

    ctypedef struct IHostWndVtbl:
        HWND CreateEx(IHostWnd* this, HWND hWndParent, DWORD dwStyle, DWORD dwExStyle, int x, int y, int nWidth, int nHeight, IXmlNode *xmlInit)
        HWND Create(IHostWnd* this, HWND hWndParent, int x, int y, int nWidth, int nHeight)
        void SetLayoutId(IHostWnd* this, LPCTSTR pszLayoutId)
        IWindow* GetIRoot(IHostWnd* this)
        IWindow* FindIChildByID(IHostWnd* this, int nId)
        IWindow* FindIChildByName(IHostWnd* this, LPCWSTR pszName)
        INcPainter* GetNcPainter(IHostWnd* this)
        BOOL ShowWindow(IHostWnd* this, int nCmdShow)
        void SetEventHandler(IHostWnd* this, FunCallback fun, void*ctx)
        # EventHandlerInfo* GetEventHandler(IHostWnd* this)
        BOOL AnimateHostWindow(IHostWnd* this, DWORD dwTime, DWORD dwFlags)
        UINT setTimeout(IHostWnd* this, LPCSTR pszScriptFunc, UINT uElapse)
        UINT setInterval(IHostWnd* this, LPCSTR pszScriptFunc, UINT uElapse)
        void clearTimer(IHostWnd* this, UINT uID)

    ctypedef struct IHostWnd: # (INativeWnd)
        IHostWndVtbl* lpVtbl

    ctypedef struct IHostDialogVtbl:
        const MSG* GetCurrentMessage(IHostDialog* this)
        IWindow* GetIRoot(IHostDialog* this)
        INcPainter* GetNcPainter(IHostDialog* this)
        INT_PTR DoModal(IHostDialog* this, HWND hParent,DWORD dwStyle,DWORD dwExStyle)
        void EndDialog(IHostDialog* this, INT_PTR nResult)

    ctypedef struct IHostDialog:
        IHostDialogVtbl* lpVtbl
    
    ctypedef struct IStringA:
        pass

    ctypedef struct IStringWVtbl:
        int GetLength(const IStringW* this)
        BOOL IsEmpty(const IStringW* this)
        void Empty(IStringW* this)
        wchar_t GetAt(const IStringW* this, int nIndex)
        void SetAt(IStringW* this, int nIndex, wchar_t ch)
        const wchar_t* c_str(const IStringW* this)
        int Compare(const IStringW* this, const wchar_t* psz)
        int CompareNoCase(const IStringW* this, const wchar_t* psz)
        void TrimBlank(IStringW* this)
        int InsertChar(IStringW* this, int nIndex, wchar_t ch)
        int Insert(IStringW* this, int nIndex, const wchar_t* psz)
        int Delete(IStringW* this, int nIndex, int nCount)
        int ReplaceChar(IStringW* this, wchar_t chOld, wchar_t chNew)
        int Replace(IStringW* this, const wchar_t* pszOld, const wchar_t* pszNew)
        int Remove(IStringW* this, wchar_t chRemove)
        int FindChar(const IStringW* this, wchar_t ch, int nStart)
        int ReverseFind(const IStringW* this, wchar_t ch)
        int Find(const IStringW* this, const wchar_t* pszSub, int nStart)
        wchar_t* GetBuffer(IStringW* this, int nMinBufLength)
        void  ReleaseBuffer(IStringW* this, int nNewLength)
        wchar_t*  GetBufferSetLength(IStringW* this, int nNewLength)
        void  SetLength(IStringW* this, int nLength)
        void  Copy(IStringW* this, const IStringW* src)
        void  Assign(IStringW* this, LPCWSTR src)
        void  Assign2(IStringW* this, LPCWSTR src,int nLen)
        LPVOID GetPrivData(const IStringW* this)

    ctypedef struct IStringW: # (IObjRef)
        IStringWVtbl* lpVtbl

    ctypedef IStringW IStringT
    
    ctypedef struct IXmlDocVtbl:
        LPVOID GetPrivPtr(IXmlDoc* this)
        void Reset(IXmlDoc* this)
        void Copy(IXmlDoc* this, const IXmlDoc* proto)
        BOOL LoadString(IXmlDoc* this, const wchar_t* contents, unsigned int options)
        BOOL LoadFileA(IXmlDoc* this, const char* path, unsigned int options, XmlEncoding encoding)
        BOOL LoadFileW(IXmlDoc* this, const wchar_t* path, unsigned int options , XmlEncoding encoding)
        BOOL LoadBuffer(IXmlDoc* this, const void* contents, size_t size, unsigned int options , XmlEncoding encoding)
        BOOL LoadBufferInplace(IXmlDoc* this, void* contents, size_t size, unsigned int options , XmlEncoding encoding)
        BOOL LoadBufferInplaceOwn(IXmlDoc* this, void* contents, size_t size, unsigned int options , XmlEncoding encoding )
        void GetParseResult(IXmlDoc* this, XmlParseResult *pResult)
        void SaveBinary(IXmlDoc* this, FILE *f)
        BOOL SaveFileA(IXmlDoc* this, const char* path, const wchar_t* indent , unsigned int flags, XmlEncoding encoding)
        BOOL SaveFileW(IXmlDoc* this, const wchar_t* path, const wchar_t* indent , unsigned int flags, XmlEncoding encoding)
        IXmlNode* Root(IXmlDoc* this)

    ctypedef struct IXmlDoc:
        IXmlDocVtbl* lpVtbl

    ctypedef struct IXmlNodeVtbl:
        void ToString(const IXmlNode* this, IStringW*out)
        LPVOID GetPrivPtr(const IXmlNode* this)
        BOOL Empty(const IXmlNode* this)
        const wchar_t* Name(const IXmlNode* this)
        const wchar_t* Value(const IXmlNode* this)
        const wchar_t* Text(const IXmlNode* this)
        BOOL set_userdata(IXmlNode* this, int data)
        int get_userdata(const IXmlNode* this)
        IXmlAttr* Attribute(const IXmlNode* this, const wchar_t* name,BOOL bCaseSensitive)
        IXmlAttr* FirstAttribute(const IXmlNode* this)
        IXmlAttr* LastAttribute(const IXmlNode* this)
        IXmlNode* Child(const IXmlNode* this, const wchar_t* name,BOOL bCaseSensitive)
        IXmlNode* FirstChild(const IXmlNode* this)
        IXmlNode* LastChild(const IXmlNode* this)
        IXmlNode* NextSibling(const IXmlNode* this)
        IXmlNode* PrevSibling(const IXmlNode* this)
        IXmlNode* NextSibling2(const IXmlNode* this, const wchar_t* name,BOOL bCaseSensitive)
        IXmlNode* PrevSibling2(const IXmlNode* this, const wchar_t* name,BOOL bCaseSensitive)

    ctypedef struct IXmlNode: # (IObjRef)
        IXmlNodeVtbl* lpVtbl

    ctypedef struct IXmlAttrVtbl:
        LPVOID GetPrivPtr(const IXmlAttr* this)
        BOOL Empty(const IXmlAttr* this)
        const wchar_t* Name(const IXmlAttr* this)
        const wchar_t* Value(const IXmlAttr* this)
        BOOL set_userdata(IXmlAttr* this, int data)
        int get_userdata(const IXmlAttr* this)
        IXmlAttr* Next(IXmlAttr* this)
        IXmlAttr* Prev(IXmlAttr* this)

    ctypedef struct IXmlAttr: # (IObjRef)
        IXmlAttrVtbl* lpVtbl

    ctypedef struct IResProviderVtbl:
        BOOL Init(IResProvider* this, WPARAM wParam, LPARAM lParam)
        BOOL HasResource(IResProvider* this, LPCTSTR pszType, LPCTSTR pszResName)
        HICON LoadIcon(IResProvider* this, LPCTSTR pszResName, int cx, int cy)
        HBITMAP LoadBitmap(IResProvider* this, LPCTSTR pszResName)
        HCURSOR LoadCursor(IResProvider* this, LPCTSTR pszResName)
        IBitmapS* LoadImage(IResProvider* this, LPCTSTR pszType, LPCTSTR pszResName)
        IImgX* LoadImgX(IResProvider* this, LPCTSTR pszType, LPCTSTR pszResName)
        size_t GetRawBufferSize(IResProvider* this, LPCTSTR pszType, LPCTSTR pszResName)
        BOOL GetRawBuffer(IResProvider* this, LPCTSTR pszType, LPCTSTR pszResName, LPVOID pBuf, size_t size)
        void EnumResource(IResProvider* this, EnumResCallback funEnumCB, LPARAM lp)

    ctypedef struct IResProvider:
        IResProviderVtbl* lpVtbl
    
    ctypedef struct IEvtSlotVtbl:
        long Release(IEvtSlot* this)
        BOOL Run(IEvtSlot* this, IEvtArgs * pArg)
        IEvtSlot* Clone(IEvtSlot* this)
        BOOL Equal(IEvtSlot* this, const IEvtSlot *sour)
        UINT GetSlotType(IEvtSlot* this)

    ctypedef struct IEvtSlot:
        IEvtSlotVtbl* lpVtbl
    
    ctypedef struct IMenuVtbl:
        BOOL Attach(IMenu* this, HMENU hMenu)
        HMENU Detach(IMenu* this)
        HMENU GetHMenu(IMenu* this)
        BOOL LoadMenu(IMenu* this, LPCTSTR resId)
        BOOL LoadMenu2(IMenu* this, IXmlNode *xmlMenu)
        void SetIconSkin(IMenu* this, ISkinObj* icons)
        BOOL InsertMenu(IMenu* this, UINT uPosition,UINT uFlags,UINT_PTR nIDNewItem,LPCTSTR strText,int iIcon,HICON hIcon)
        BOOL AppendMenu(IMenu* this, UINT uFlags,UINT_PTR uIDNewItem,LPCTSTR lpNewItem,int iIcon,HICON hIcon)
        BOOL CheckMenuItem(IMenu* this, UINT uIdCheckItem, UINT uCheck)
        BOOL CheckMenuRadioItem(IMenu* this, UINT idFirst,UINT idLast,UINT idCheck,UINT uFlags)
        BOOL DeleteMenu(IMenu* this, UINT uPosition, UINT uFlags)
        UINT TrackPopupMenu(IMenu* this, UINT uFlags,int x,int y,HWND hWnd,LPCRECT prcRect,int nScale)
        void DestroyMenu(IMenu* this)
        BOOL ModifyMenuString(IMenu* this, UINT uPosition, UINT uFlags, LPCTSTR lpItemString)
        BOOL SetMenuUserData(IMenu* this, UINT uPosition, UINT uFlags, ULONG_PTR ulUserData)
        ULONG_PTR GetMenuUserData(IMenu* this, UINT uPosition, UINT uFlags)
        DWORD GetContextHelpId(IMenu* this)
        void SetContextHelpId(IMenu* this, DWORD dwId)
        HMENU GetSubMenu(IMenu* this, int nPos)

    ctypedef struct IMenu:
        IMenuVtbl* lpVtbl
    
    ctypedef struct IMenuExVtbl:
        BOOL LoadMenu(IMenuEx* this, LPCTSTR resId)
        BOOL LoadMenu2(IMenuEx* this, IXmlNode *xmlMenu)
        BOOL InsertMenu(IMenuEx* this, UINT uPosition, UINT uFlags, int id, LPCTSTR strText, int iIcon)
        BOOL AppendMenu(IMenuEx* this, UINT uFlags, int id, LPCTSTR lpNewItem, int iIcon)
        BOOL CheckMenuItem(IMenuEx* this, UINT uIdCheckItem, UINT uCheck)
        BOOL CheckMenuRadioItem(IMenuEx* this, UINT idFirst,UINT idLast,UINT idCheck,UINT uFlags)
        BOOL DeleteMenu(IMenuEx* this, UINT uPosition, UINT uFlags)
        UINT TrackPopupMenu(IMenuEx* this, UINT uFlags, int x, int y, HWND hWnd, int nScale)
        void DestroyMenu(IMenuEx* this)
        BOOL ModifyMenuString(IMenuEx* this, UINT uPosition, UINT uFlags, LPCTSTR lpItemString)
        BOOL SetMenuUserData(IMenuEx* this, UINT uPosition, UINT uFlags, ULONG_PTR ulUserData)
        ULONG_PTR GetMenuUserData(IMenuEx* this, UINT uPosition, UINT uFlags)
        DWORD GetContextHelpId(IMenuEx* this)
        void SetContextHelpId(IMenuEx* this, DWORD dwId)
        IMenuEx* GetSubMenu(IMenuEx* this, int nPos)

    ctypedef struct IMenuEx:
        IMenuExVtbl* lpVtbl
